﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Share/Index.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">

<script language="javascript" type="text/javascript">
    var mylist, bookType = [];
    $(document).ready(function () {
        mylist = new TurnPage("mylist");
        mylist.pageSize = 8;
        mylist.callback = function () { ajax(); };

        function ajax() {
            var bookname = $.trim($("#seekForm :input[name=bookname]").val());
            var in_s = $.trim($("#seekForm :input[name=in_s]").val());
            var in_e = $.trim($("#seekForm :input[name=in_e]").val());

            var param = { pagesize: mylist.pageSize, pageno: mylist.currPage, bookname: bookname, in_s: in_s, in_e: in_e };
            $.post("/librarybook/getloanBooks.html?" + (new Date()).getTime(), param, function (data) {
                data = $.evalJSON(data);
                if (mylist.currPage == 1) {
                    mylist.total = $.grep(data, function (n, i) { return typeof (n.total) == "number"; })[0].total;
                    data = $.grep(data, function (n, i) { return typeof (n.total) == "undefined"; });
                }
                loadDta(data);
            });
        }

        var loadDta = function (list) {
            var sp = [];
            $("#mainTable tbody[name=mainlist]").html("");
            $.each(list, function (i, n) {
                sp.push('<tr>');
                sp.push('<td>' + n.lb_bookName + '</td>');
                sp.push('<td>' + n.lb_author + '</td>');
                sp.push('<td>' + bookType["x" + n.lbi_state] + '</td>');
                sp.push('<td>' + n.u_name + '</td>');
                sp.push('<td>' + n.u_tel1 + '</td>');
                sp.push('<td>' + n.u_address + '</td>');
                sp.push('</tr>');
            });
            $("#mainTable tbody[name=mainlist]").append(sp.join(''));
            if (sp.length == 0) alert('没有符合条件的数据');
            $("#pager").html(mylist.getOutput());
        }
        $("input[name=buttSeek]").click(function () {
            mylist.currPage = 1;
            ajax();
        });
    });
</script>
    <table cellspacing="0" id="seekForm">
        <tr>
            <th>
                借出图书查询
            </th>
        </tr>
        <tr>
            <td>
                书名：<input type="text" name="bookname" />借出时间：<input type="text" size="15" name="in_s" value="<%=System.DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd")%>" class="date" />
                至<input type="text" size="15" name="in_e" value="<%=System.DateTime.Now.ToString("yyyy-MM-dd") %>" class="date" />
                                                   <script type="text/javascript">
                                                       $(document).ready(function () {
                                                           $(function () {
                                                               $("#seekForm :input[name=in_s]").datepicker({
                                                                   duration: '',
                                                                   showTime: false,           //日期控件是否显示时间
                                                                   constrainInput: false,
                                                                   stepMinutes: 1,
                                                                   stepHours: 1,
                                                                   altTimeField: '',                                            
                                                                   changeMonth: true,
                                                                   yearRange: '-40:+1',changeYear: true,
                                                                   time24h: true  //是否是24h制
                                                               });
                                                           });
                                                           $(function () {
                                                               $("#seekForm :input[name=in_e]").datepicker({
                                                                   duration: '',
                                                                   showTime: false,           //日期控件是否显示时间
                                                                   constrainInput: false,
                                                                   stepMinutes: 1,
                                                                   stepHours: 1,
                                                                   altTimeField: '',                                            
                                                                   changeMonth: true,
                                                                   yearRange: '-40:+1',changeYear: true,
                                                                   time24h: true  //是否是24h制
                                                               });
                                                           });
                                                       });
                     </script>
                <input type="button" name="buttSeek" value="查询" onclick="" class="btn1" />
            </td>
        </tr>
    </table>
        <table  id="mainTable" cellspacing="0">
        <caption style="color: red; font-size: 15px; font-weight: bold">图书出借列表</caption>
        <tr>
                    <th>
            书名
            </th>
            <th>
            作者
            </th>
            <th>
            状态
            </th>
            <th>
                学员姓名
            </th>
            <th >
                联系方式
            </th>
            <th>
                地址
            </th>
            </tr>
        <tbody name="mainlist">
        
        </tbody>
    </table>
             <%
                 foreach (string s in Enum.GetNames(typeof(DAL.Enums.bookstate)))
                 {
                     int _v = (int)Enum.Parse(typeof(DAL.Enums.bookstate), s);
                     Response.Write("<script>bookType['x" + _v + "']='" + s + "';</script>");
                 }
             %>
</asp:Content>
